package NWish.properties.object3ds
{
	import NWish.Misc;
	import NWish.json.OrderDict;
	import NWish.properties.Properties;
	
	import away3d.containers.Scene3D;
	
	
	public class Object3DProperties extends Properties 
	{
		public function Object3DProperties(parent)
		{
			super(parent);
			
			var keys
			= 
				['name'
				,'x'
				,'y'
				,'z'
				,'rotationX'
				,'rotationY'
				,'rotationZ'
				,'scaleX'
				,'scaleY'
				,'scaleZ'
				];
			addPropertieKeys('Object3D',keys);
			
			var keysRead
			= 
				['position'
				,'pivotPoint'
				,'eulers'
				
				,'originalName'
				,'assetNamespace'
				,'assetFullPath'
				];
			addPropertieKeys_read('Object3D',keysRead);
		}
		
		private var count = 0;
		override public function dictToProperties(dict,obj,scene:Scene3D,isloading)
		{
			if(obj.name == null || obj.name == '')
				dict.name = 'unknow';
			else if(dict.name == null || dict.name == '')
				dict.name = obj.name;
			
			super.dictToProperties(dict,obj,scene,isloading);
			
			obj.name = Misc.validName(obj.name);
			
			while(Misc.getChildByNameInScene(obj.name,scene,obj))
			{
				obj.name += '_' + count;
				++count;
			}
		}
		
		static private var _index = 0;
		override protected function index(obj)
		{
			return ':' + _index++;
		}
	}

}